import 'package:flutter/material.dart';

import 'package:flutter_app_open_camera/constant/Constants.dart';
import 'package:flutter_app_open_camera/main.dart';
import 'package:flutter_app_open_camera/page/img_picker_page.dart';
import 'package:flutter_app_open_camera/page/main_page.dart';
import 'package:flutter_app_open_camera/resource/theme/dark_mode_provider.dart';
import 'package:flutter_app_open_camera/resource/theme/theme_icon.dart';
import 'package:flutter_app_open_camera/utils/route_utils.dart';
import 'package:sp_util/sp_util.dart';

import 'login_page.dart';

class SplashPage extends StatefulWidget {
  @override
  _SplashPageState createState() => _SplashPageState();
}

class _SplashPageState extends State<SplashPage> {
  @override
  void initState() {
    super.initState();
    _initAsync();
  }

  Future<void> _initAsync() async {
    await SpUtil.getInstance();
    setTheme(context);
    // WidgetsBinding.instance.addPostFrameCallback((timeStamp) async {});
    bool isRealName = SpUtil.getBool(Constants.IS_REALNAME, defValue: false);
    if (!isRealName) {
      launchAndBack(context, LoginPage());
    } else {
      launchAndBack(context, MainPage());
    }
  }

  @override
  Widget build(BuildContext context) {
    return Container();
  }
}
